package List;

import java.util.ArrayList;
import java.util.LinkedList;

public class ListDemo3 {
    public static void main(String[] args) {
        ArrayList<String> arrayList=new ArrayList<>();
        arrayList.add("zhangsan");
        arrayList.add("lisi");
        System.out.println(arrayList);
        System.out.println(arrayList.get(1));
//        创建一个链表对象linkedList
        LinkedList<String> linkedList=new LinkedList<>();
        linkedList.add("zhangsan");
        linkedList.add("lisi");
//        addfirst增加首个元素
        linkedList.addFirst("wangwu");
        linkedList.addLast("zhaolv");
        System.out.println(linkedList);
        linkedList.set(1,"lose");
        System.out.println(linkedList);
//        linkedList集合，底层是双向链表结构，查找元素的时候会从头部或者尾部逐个查找
        System.out.println(linkedList.get(2));
    }
}
